#!/usr/bin/python
# Copyright 2011, Kitware, Inc.

import sys

if len(sys.argv) == 2:
    filename = sys.argv[1]
else:
    filename = '/home/tutorial/Tutorial/Data/cthead1.png'

import SimpleITK as sitk
import pylab

image = sitk.ReadImage(filename)
image_array = sitk.GetArrayFromImage(image)

sitk.Show(image)

blurred = sitk.RecursiveGaussian(image, 4)
blurred_array = sitk.GetArrayFromImage(blurred)

# Generate a normal and blurred histogram
pylab.figure()
pylab.hist(image_array.flatten())
pylab.figure()
pylab.hist(blurred_array.flatten())
pylab.show()

# Threshold the image properly
thresh = sitk.Threshold(image, 210, 255)

sitk.Show(thresh)
